﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SharpSvn;
using log4net;

namespace PreCommitHook
{
    public class SVNChangeItemInfo : ISVNChangeInfo
    {
        private readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

        private SvnChangeInfoEventArgs revisionInfo;
        
        public SVNChangeItemInfo(SvnChangeInfoEventArgs revisionInfo)
        {
            	this.revisionInfo = revisionInfo;
        }

        #region ISVNChangeInfoEventArgs Members

        public string LogMessage
        {
            get
			{
				return revisionInfo.LogMessage;
			}
        }

        public string Author
        {
            get 
            {
                return revisionInfo.Author;
            }
        }

        /// <summary>
        /// collection of the items that participate in the commit operation
        /// </summary>
        public IList<SVNItem> ChangedItems
        {
            get
            {
                IList<SVNItem> changedPaths = new List<SVNItem>();
                foreach (SvnChangeItem changedPath in this.revisionInfo.ChangedPaths)
                {
                    changedPaths.Add(new SVNItem(changedPath.Path, changedPath.Action, changedPath.NodeKind));
                }
                return changedPaths;
                
            }
        }

        #endregion
    }
}
